package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.PropertyDeviceAlarmInfoDTO;
import com.itlong.cloud.POJO.VO.property.CloudElevatorVO;
import com.itlong.cloud.POJO.VO.property.PropertyDeviceAlarmInfoVO;
import com.itlong.cloud.equip.property.IPropertyDeviceAlarmMessageServiceClient;
import com.itlong.cloud.property.service.IPropertyDeviceAlarmService;
import com.itlong.cloud.utils.page.PageByVisitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <desc>
 *      设备告警暴露实现类
 * </desc>
 *
 * @createDate 2021/05/31
 **/
@RestController
public class PropertyDeviceAlarmServiceResource implements IPropertyDeviceAlarmMessageServiceClient {

    @Autowired
    private IPropertyDeviceAlarmService iPropertyDeviceAlarmService;

    /**
     * <desc>
     *      实时抓拍或撤消告警
     * <desc/>
     *
     * @param  alarmInfoDTO 告警相关数据
     * @return
     * @author Juguang.S
     * @createDate 2021-05-31
     */
    @Override
    @PostMapping("/property/alarmMessage/realTimeSnapshotOrCancelAlarm")
    public void realTimeSnapshotOrCancelAlarm(@RequestBody PropertyDeviceAlarmInfoDTO alarmInfoDTO) throws Exception {
        iPropertyDeviceAlarmService.realTimeSnapshotOrCancelAlarm(alarmInfoDTO);
    }

    /**
     * <desc>
     *      根据告警id查询电梯相关信息
     * <desc/>
     *
     * @param  alarmId 告警ID
     * @return
     * @author Juguang.S
     * @createDate 2021-05-31
     */
    @Override
    @RequestMapping(path = "/property/alarmMessage/getElevatorInfoByAlarmId",method = RequestMethod.POST)
    public CloudElevatorVO getElevatorInfoByAlarmId(@RequestParam("alarmId") String alarmId) throws Exception{
        return iPropertyDeviceAlarmService.getElevatorInfoByAlarmId(alarmId);
    }

    /**
     * <desc>
     *      获取告警消息列表
     * </desc>
     *
     * @param alarmInfoDTO 获取获取告警消息列表DTO
     * @return 分页告警消息列表
     * @author Juguang.S
     * @createDate 2021/06/07
     */
    @PostMapping(path = "/property/alarmMessage/getPage")
    public PageByVisitor<PropertyDeviceAlarmInfoVO> getPage(@RequestBody PropertyDeviceAlarmInfoDTO alarmInfoDTO) throws Exception{
        return iPropertyDeviceAlarmService.getPage(alarmInfoDTO);
    }

    /**
     * <desc>
     *      修改设备告警消息的状态。
     * <desc/>
     *
     * @param  messageId 消息ID 多个以逗号隔开
     * @param  type 修改类型 0删除 1修改状态为已读
     * @return
     * @author Juguang.S
     * @createDate 2021/06/07
     */
    @Override
    @RequestMapping(path = "/property/alarmMessage/updateMessageInfo",method = RequestMethod.POST)
    public void updateMessageInfo(@RequestParam("messageId") String messageId,@RequestParam("type") String type) {
        iPropertyDeviceAlarmService.updateMessageInfo(messageId,type);
    }
}
